package com.ruoyi.common.utils;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.util.encoders.Hex;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.spec.ECGenParameterSpec;

public class KeyGenerator {

    public static final String algorithm = "secp256r1";
    public static final String ALGO_EC = "EC";

    public static void main(String[] args) throws Exception {
        KeyPairGenerator g = KeyPairGenerator.getInstance(ALGO_EC, new BouncyCastleProvider());
        ECGenParameterSpec kpgparams = new ECGenParameterSpec(algorithm);
        g.initialize(kpgparams);
        KeyPair keyPair = g.generateKeyPair();
        System.out.println("API Key: " + Hex.toHexString(keyPair.getPublic().getEncoded()));
        System.out.println("API Secret: " + Hex.toHexString(keyPair.getPrivate().getEncoded()));
    }
}
